Skip to content

Stabilize the avx512 target features #138940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sayantn
Copy link
Contributor

@sayantn sayantn commented Mar 25, 2025

This PR stabilizes the AVX512 target features - see this comment.

Tracking Issue - #44839

DO NOT MERGE now, because the runtime detection for 5 features are guarded on avx512_target_feature, so rust-lang/stdarch#1757 has a temporary fix which changes the feature name of these. We need to FCP these together with all the AVX512 target features, after that and merge of rust-lang/stdarch#1760, we can again do a stdarch update and merge this.

The target feature UI tests have been changed to x87 (chosen because this is very unlikely to stablize ever, please comment if some other feature will be better)

related: #111137

@rustbot
Copy link
Collaborator

rustbot commented Mar 25, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot
Copy link
Collaborator

rustbot commented Mar 25, 2025

⚠️ Warning ⚠️

  • These commits modify submodules.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 25, 2025
@rust-log-analyzer

This comment has been minimized.

@sayantn

This comment was marked as resolved.

@sayantn sayantn force-pushed the stabilize-avx512 branch 2 times, most recently from 1be9f75 to 94d0e36 Compare March 25, 2025 19:51
@rustbot
Copy link
Collaborator

rustbot commented Mar 25, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@Amanieu Amanieu added the I-lang-nominated Nominated for discussion during a lang team meeting. label Mar 25, 2025
@Amanieu
Copy link
Member

Amanieu commented Mar 25, 2025

Nominating for T-lang FCP. This stabilizes the AVX512 target features which is a per-requisite for stabilizing the AVX-512 intrinsics tracked in #111137.

@Amanieu Amanieu added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 25, 2025
@ehuss
Copy link
Contributor

ehuss commented Mar 26, 2025

Can you also send a PR to update https://github.com/rust-lang/reference/blob/master/src/attributes/codegen.md#x86-or-x86_64?

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@Amanieu Amanieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These features are for the various AVX512 sub-features. We have already stabilized some of these names in is_x86_feature_detected! so the language level name should match.

@rustbot
Copy link
Collaborator

rustbot commented Apr 10, 2025

⚠️ Warning ⚠️

  • Some commits in this PR modify submodules.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 16, 2025

Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Apr 16, 2025
@traviscross
Copy link
Contributor

@rfcbot reviewed

1 similar comment
@tmandry
Copy link
Member

tmandry commented Apr 16, 2025

@rfcbot reviewed

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Apr 16, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Apr 16, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@joshtriplett joshtriplett added the relnotes Marks issues that should be documented in the release notes of the next release. label Apr 16, 2025
@traviscross traviscross removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Apr 16, 2025
@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@bors
Copy link
Collaborator

bors commented Apr 16, 2025

☔ The latest upstream changes (presumably #139914) made this pull request unmergeable. Please resolve the merge conflicts.

@sayantn
Copy link
Contributor Author

sayantn commented Apr 24, 2025

I discovered a related mistake in LLVM. Basically

  • avx512f - GCC and Intel implies only avx2, LLVM also does fma and f16c
  • avx512fp16 - GCC and Intel implies only avx512bw, LLVM also does avx512dq and avx512vl

I have filed llvm/llvm-project#136209

For avx512f, this requirement is probably justified (see this comment). We just need to ensure that fma and f16c are required for avx512f in std_detect. I have sent a PR (rust-lang/stdarch#1781).

But we need to settle the avx512fp16 business.

This has the potential to generate invalid code (even in safe Rust, e.g https://godbolt.org/z/d3M674nY6 - here only avx512fp16 is enabled, but LLVM is generating vaddph.128, which is not available without avx512vl). Even if #140002 passes though, this invalid codegen will persist, as it is an LLVM issue. So essentially we have 2 options

  • Don't adhere to Intel's spec. We say that avx512fp16 implies avx512vl in rustc_target/target_feature.rs, and only enable it in std_detect when avx512vl is available. This is safe, with the caveat that if Intel releases a CPU with avx512fp16, but not avx512vl (currently none exist) Rust will just not detect avx512fp16 there.
  • Delay the stabilization of avx512fp16 for now. We wait for the upstream LLVM issue to be fixed (which I believe will take a long time).

I don't think we have to delay the stabilization of any other avx512 target feature.

cc @rust-lang/lang
cc @rust-lang/wg-llvm

@bors
Copy link
Collaborator

bors commented Apr 24, 2025

☔ The latest upstream changes (presumably #139309) made this pull request unmergeable. Please resolve the merge conflicts.

@traviscross
Copy link
Contributor

@rfcbot concern llvm-mistake
@rustbot labels +I-lang-nominated

Good catch. We'll be sure to discuss.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Apr 24, 2025
@rustbot rustbot added the I-lang-nominated Nominated for discussion during a lang team meeting. label Apr 24, 2025
@rfcbot rfcbot removed the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. I-lang-nominated Nominated for discussion during a lang team meeting. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.